import { Request } from '../../utils/util.js'
let request = new Request()
let app = getApp()
Component({

  /**
   * 页面的初始数据
   */
  data: {
    userType : 1,
    numbers : {},
    userInfo : {
      avatar : '',
      nickname : ''
    }
  },

  methods : {
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function (options) {
      this.setData({
        userInfo: app.globalData.userInfo,
        userType: app.globalData.userInfo.user_type
      })
    },


    onReady: function () {

    },


    onShow: function () {

    }
  },
  pageLifetimes: {
    show() { //获取位置
      if (typeof this.getTabBar === 'function' &&
        this.getTabBar()) {
        this.getTabBar().setData({
          selectedIndex: 4
        })
      }
      if (!app.globalData.userNumber) {
        request.get('user/number', res => {
          app.globalData.userNumber = res.data
          this.setData({
            numbers: res.data
          })
        })
      }
    }
  }
})